<template>
  <div class="main">
    <el-container class="main-content">
      <el-aside :width="isCollapse ? '64px' : '237px'">
        <!-- 左侧菜单栏 -->
        <nav-menu :collapse="isCollapse"></nav-menu>
      </el-aside>
      <el-container class="page">
        <el-header class="page-header">
          <nav-header @foldChange="headerFoldChange"></nav-header>
        </el-header>
        <el-main class="page-content">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import NavMenu from '@/components/nav-menu'
import NavHeader from '@/components/nav-header'
export default defineComponent({
  components: { NavMenu, NavHeader },
  setup() {
    // 控制菜单栏宽度
    const isCollapse = ref(false)
    const headerFoldChange = (isFold: boolean) => {
      isCollapse.value = isFold
    }
    return { isCollapse, headerFoldChange }
  }
})
</script>

<style scoped lang="less">
.main {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  .main-content,
  .page {
    height: 100%;
    .page-header {
      height: 60px !important;
      padding: 0;
    }
    .page-content {
      height: calc(100% -60px);
      width: 100%;
    }
  }
  .el-aside {
    overflow-x: hidden;
    overflow-y: auto;
    cursor: pointer;
    transition: width 0.3s linear;
    scrollbar-width: none;
    -ms-overflow-style: none;
    &::-webkit-scrollbar {
      display: none;
    }
  }

  .el-main {
    background-color: #f0f2f5;
  }
}
</style>
